package com.base.self.controller;

import com.base.log.LoginAn;
import com.base.result.ResponseResult;
import com.base.self.dto.commodityClassify.*;
import com.base.self.service.ICommodityClassifyService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.validation.Valid;

/**
 * 商品分类
 *
 * @author XiFYuW
 * @since 2020-11-13
 */
@RestController
@RequestMapping("/admin/commodityClassify")
public class CommodityClassifyController {
    private final ICommodityClassifyService iCommodityClassifyService;

    public CommodityClassifyController(ICommodityClassifyService iCommodityClassifyService) {
        this.iCommodityClassifyService = iCommodityClassifyService;
    }

    @GetMapping(value = "/commodityClassifyIndex")
    @LoginAn
    public ModelAndView commodityIndex() {
        return new ModelAndView("self/index_commodity_classify");
    }

    @PostMapping(value = "/commodityClassifyWebList")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityClassifyWebList(@Valid final CommodityClassifyWebListDTO commodityClassifyWebListDTO) {
        return iCommodityClassifyService.commodityClassifyWebList(commodityClassifyWebListDTO);
    }

    @PostMapping(value = "/commodityClassifyAdd")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityClassifyAdd(@Valid final CommodityClassifyAddDTO commodityClassifyAddDTO) {
        return iCommodityClassifyService.commodityClassifyAdd(commodityClassifyAddDTO);
    }

    @PostMapping(value = "/commodityClassifyUpdate")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityClassifyUpdate(@Valid final CommodityClassifyUpdateDTO commodityClassifyUpdateDTO) {
        return iCommodityClassifyService.commodityClassifyUpdate(commodityClassifyUpdateDTO);
    }

    @PostMapping(value = "/commodityClassifyDelete")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult commodityClassifyDelete(@Valid final CommodityClassifyDeleteDTO commodityClassifyDeleteDTO) {
        return iCommodityClassifyService.commodityClassifyDelete(commodityClassifyDeleteDTO);
    }

    @PostMapping(value = "/getClassifyPidSelectData")
    @Validated
    @LoginAn(isRe = true)
    public ResponseResult getClassifyPidSelectData(@Valid final ClassifyPidSelectDataDTO classifyPidSelectDataDTO) {
        return iCommodityClassifyService.getClassifyPidSelectData(classifyPidSelectDataDTO);
    }
}

